<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        var obj = {
            name: "孙悟空",
            age: 100
        }

        console.log(obj);
        // stringify()方法可以将js对象转换为json字符
        var str = JSON.stringify(obj); //{"name":"孙悟空","age":100}
        console.log(str);
        // parse()方法可以将JSON字符串解析为js对象
        var obj1 = JSON.parse(str);
        console.log(obj1);
    </script>


</body>

</html>